]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
st/adjustment: Add ::actor property
authorJonas Ådahl <jadahl@gmail.com>
Tue, 16 Jun 2020 20:03:07 +0000 (22:03 +0200)
committerGeorges Basile Stavracas Neto <georges.stavracas@gmail.com>
Thu, 2 Jul 2020 20:50:03 +0000 (20:50 +0000)
Will be used by transitions to set the timeline actor.

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1299

js/ui/overviewControls.js
js/ui/unlockDialog.js
src/st/st-adjustment.c
src/st/st-adjustment.h
src/st/st-scroll-view.c

index 9f73408d0c88f531e9380354fc372f0ab07a147e..3d665dc1e7d71245b65e7b9f924bd3351f02cad3 100644 (file)
@@ -423,6 +423,7 @@ class ControlsManager extends St.Widget {
         let activeWorkspaceIndex = workspaceManager.get_active_workspace_index();
 
         this._workspaceAdjustment = new St.Adjustment({
+            actor: this,
             value: activeWorkspaceIndex,
             lower: 0,
             page_increment: 1,
index c6d70d3382368accf94c8af9fef120bf1ce8b043..ad3aab977a7cf2f56c353648fe26439e94f138c2 100644 (file)
@@ -485,6 +485,7 @@ var UnlockDialog = GObject.registerClass({
         this._gdmClient = new Gdm.Client();
 
         this._adjustment = new St.Adjustment({
+            actor: this,
             lower: 0,
             upper: 2,
             page_size: 1,
index dfd1efe6771a6c4df3509103f160c742d34cf77b..eb170488f89075f78e8cfe4e8c92a1f12f3fbfad 100644 (file)
@@ -41,6 +41,8 @@ typedef struct _StAdjustmentPrivate StAdjustmentPrivate;
 
 struct _StAdjustmentPrivate
 {
+  ClutterActor *actor;
+
   /* Do not sanity-check values while constructing,
    * not all properties may be set yet. */
   guint is_constructing : 1;
@@ -66,6 +68,7 @@ enum
 {
   PROP_0,
 
+  PROP_ACTOR,
   PROP_LOWER,
   PROP_UPPER,
   PROP_VALUE,
@@ -106,9 +109,21 @@ static gboolean st_adjustment_set_page_increment (StAdjustment *adjustment,
 static gboolean st_adjustment_set_page_size      (StAdjustment *adjustment,
                                                   gdouble       size);
 
+static ClutterActor *
+st_adjustment_get_actor (ClutterAnimatable *animatable)
+{
+  StAdjustment *adjustment = ST_ADJUSTMENT (animatable);
+  StAdjustmentPrivate *priv = st_adjustment_get_instance_private (adjustment);
+
+  g_warn_if_fail (priv->actor);
+
+  return priv->actor;
+}
+
 static void
 animatable_iface_init (ClutterAnimatableInterface *iface)
 {
+  iface->get_actor = st_adjustment_get_actor;
 }
 
 static void
@@ -141,6 +156,10 @@ st_adjustment_get_property (GObject    *gobject,
 
   switch (prop_id)
     {
+    case PROP_ACTOR:
+      g_value_set_object (value, priv->actor);
+      break;
+
     case PROP_LOWER:
       g_value_set_double (value, priv->lower);
       break;
@@ -171,6 +190,18 @@ st_adjustment_get_property (GObject    *gobject,
     }
 }
 
+static void
+actor_destroyed (gpointer  user_data,
+                 GObject  *where_the_object_was)
+{
+  StAdjustment *adj = ST_ADJUSTMENT (user_data);
+  StAdjustmentPrivate *priv = st_adjustment_get_instance_private (adj);
+
+  priv->actor = NULL;
+
+  g_object_notify_by_pspec (G_OBJECT (adj), props[PROP_ACTOR]);
+}
+
 static void
 st_adjustment_set_property (GObject      *gobject,
                             guint         prop_id,
@@ -178,9 +209,20 @@ st_adjustment_set_property (GObject      *gobject,
                             GParamSpec   *pspec)
 {
   StAdjustment *adj = ST_ADJUSTMENT (gobject);
+  StAdjustmentPrivate *priv;
+
+  priv = st_adjustment_get_instance_private (ST_ADJUSTMENT (gobject));
 
   switch (prop_id)
     {
+    case PROP_ACTOR:
+      if (priv->actor)
+        g_object_weak_unref (G_OBJECT (priv->actor), actor_destroyed, adj);
+      priv->actor = g_value_get_object (value);
+      if (priv->actor)
+        g_object_weak_ref (G_OBJECT (priv->actor), actor_destroyed, adj);
+      break;
+
     case PROP_LOWER:
       st_adjustment_set_lower (adj, g_value_get_double (value));
       break;
@@ -217,6 +259,11 @@ st_adjustment_dispose (GObject *object)
   StAdjustmentPrivate *priv;
 
   priv = st_adjustment_get_instance_private (ST_ADJUSTMENT (object));
+  if (priv->actor)
+    {
+      g_object_weak_unref (G_OBJECT (priv->actor), actor_destroyed, object);
+      priv->actor = NULL;
+    }
   g_clear_pointer (&priv->transitions, g_hash_table_unref);
 
   G_OBJECT_CLASS (st_adjustment_parent_class)->dispose (object);
@@ -232,6 +279,11 @@ st_adjustment_class_init (StAdjustmentClass *klass)
   object_class->set_property = st_adjustment_set_property;
   object_class->dispose = st_adjustment_dispose;
 
+  props[PROP_ACTOR] =
+    g_param_spec_object ("actor", "Actor", "Actor",
+                         CLUTTER_TYPE_ACTOR,
+                         ST_PARAM_READWRITE);
+
   props[PROP_LOWER] =
     g_param_spec_double ("lower", "Lower", "Lower bound",
                          -G_MAXDOUBLE,  G_MAXDOUBLE, 0.0,
@@ -299,7 +351,8 @@ st_adjustment_init (StAdjustment *self)
 }
 
 StAdjustment *
-st_adjustment_new (gdouble value,
+st_adjustment_new (ClutterActor *actor,
+                   gdouble value,
                    gdouble lower,
                    gdouble upper,
                    gdouble step_increment,
@@ -307,6 +360,7 @@ st_adjustment_new (gdouble value,
                    gdouble page_size)
 {
   return g_object_new (ST_TYPE_ADJUSTMENT,
+                       "actor", actor,
                        "value", value,
                        "lower", lower,
                        "upper", upper,
index 302755a0970d0cd45cc92cf99426380c884c1e0d..08a0fc30a2892a085d67541e460e03c74ebb3e29 100644 (file)
@@ -48,7 +48,8 @@ struct _StAdjustmentClass
   void (* changed) (StAdjustment *adjustment);
 };
 
-StAdjustment *st_adjustment_new         (gdouble       value,
+StAdjustment *st_adjustment_new         (ClutterActor *actor,
+                                         gdouble       value,
                                          gdouble       lower,
                                          gdouble       upper,
                                          gdouble       step_increment,
index 1d2dbec8d4cc85d014e21f80a71309f055c7d20c..349c8c84099ea1b82dda339fcd9385df2b901102 100644 (file)
@@ -899,13 +899,17 @@ st_scroll_view_init (StScrollView *self)
   priv->hscrollbar_policy = ST_POLICY_AUTOMATIC;
   priv->vscrollbar_policy = ST_POLICY_AUTOMATIC;
 
-  priv->hadjustment = g_object_new (ST_TYPE_ADJUSTMENT, NULL);
+  priv->hadjustment = g_object_new (ST_TYPE_ADJUSTMENT,
+                                    "actor", self,
+                                    NULL);
   priv->hscroll = g_object_new (ST_TYPE_SCROLL_BAR,
                                 "adjustment", priv->hadjustment,
                                 "vertical", FALSE,
                                 NULL);
 
-  priv->vadjustment = g_object_new (ST_TYPE_ADJUSTMENT, NULL);
+  priv->vadjustment = g_object_new (ST_TYPE_ADJUSTMENT,
+                                    "actor", self,
+                                    NULL);
   priv->vscroll = g_object_new (ST_TYPE_SCROLL_BAR,
                                 "adjustment", priv->vadjustment,
                                 "vertical", TRUE,